package com.example.controlller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@PropertySource("classpath:/properties/redis.properties")
public class RedisController {

    // 通过yml文件的方式赋值
    @Value("${redis.host}")
    private String host;    // = "127.0.0.1";
    @Value("${redis.port}")
    private int port;       // = 6397;


    // 2、通过pro的方式赋值
    @Value("${redis2.host}")
    private String host2;
    @Value("${redis2.port}")
    private int port2;



    @RequestMapping("/getNode")
    public String getNode1(){

        return "yml文件的配置 "+host + " " +port  +"\n"+"redis.properties的配置 "+ host2 + " " +port2;
    }

}
